import requests
import json
import time

#API链接    后台获取链接地址
proxyAPI = "http://lzjasdq.user.xiecaiyun.com/api/proxies?action=getJSON&key=NPA6099A34&count=&word=&rand=false&norepeat=false&detail=false&ltime=&idshow=false"
proxyusernm = "lzjasdq"        #代理帐号
proxypasswd = "lzjasdq"        #代理密码
# url='https://www.baidu.com/'
url='https://2024.ip138.com/'

def get_proxy():
    # 获取IP
    r = requests.get(proxyAPI)
    if (r.status_code == 200):
        j = json.loads(r.text)
        if (j["success"] and len(j["result"]) > 0):
            p = j["result"][0]
            # name = input();
            proxyurl = "http://" + proxyusernm + ":" + proxypasswd + "@" + p["ip"] + ":" + "%d" % p["port"]
            proxyurl1 = "https://" + proxyusernm + ":" + proxypasswd + "@" + p["ip"] + ":" + "%d" % p["port"]
            print("proxyurl:", proxyurl)
            print("proxyurl:", proxyurl)

            proxies = {'http': proxyurl, 'https': proxyurl1}

    return  proxies